package Hot100.leetcode.editor.cn.code.双指针;
//Java：移动零
public class MoveZeroes{
    public static void main(String[] args) {
        Solution solution = new MoveZeroes().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public void moveZeroes(int[] nums) {
        //i指针和i0指针本质是索引 i0记录的是0的位置来进行交换
        //每次遇到num[i]不等于0的情况下交换nums[i] 和 nums[i0] i和i0都++；
        //如果碰到等于0的情况则i++，i0不动因为它的作用就是确保顺序和它的位置很秒因为不移动所以就是0的位置
        int i0 = 0;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i] != 0){
                int temp = nums[i];
                nums[i] = nums[i0];
                nums[i0] = temp;
                i0++;
            }
        }
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}